Using Nancy: Bootstrapper

Modified on Monday, 21 December 2015 03:24 PM by 156.75.200.57 — Categorized as: Uncategorized

public class Bootstrapper : DefaultNancyBootstrapper
    {

        protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
        {
           
            pipelines.BeforeRequest += ctx =>
            {
                if (ctx.Request.Path == "/" && !System.Web.HttpContext.Current.Request.RawUrl.EndsWith("/"))
                    return new Nancy.Responses.RedirectResponse(ctx.Request.Url.ToString() + "/",
                        Nancy.Responses.RedirectResponse.RedirectType.Permanent);
                return null;
            };

            base.ApplicationStartup(container, pipelines);
            JsonSettings.MaxJsonLength = int.MaxValue;
            pipelines.EnableCORS();
        }

               
        protected override void ConfigureConventions(NancyConventions nancyConventions)
        {
            base.ConfigureConventions(nancyConventions);
            StaticConfiguration.DisableErrorTraces = false;
            nancyConventions.MapStaticContent((file, dir) =>
            {
                dir["/dist"] = "/dist";
            });
        }
    }